package com.stockz.indicator.vsa.property;

import java.util.List;

import com.stockz.core.model.Bar;
import com.stockz.indicator.vsa.VsaBar;

public class Region extends RangeEnum {

	public static final Region OverBaught = new Region("OverBought",1,Double.MAX_VALUE,111);
	public static final Region Average = new Region("Average",2,110,91);
	public static final Region OverSold = new Region("OverSold",3,90,0);
	
	private static final Region[] regions =  new Region[]{OverBaught,Average,OverSold};
	
	public static Region[] values(){
		return regions;
	}
	
	public static void analyze(List<Bar> barList, double[] pl, int index, VsaBar vsaBar){
		if(barList == null || barList.isEmpty() || pl == null || 0 == pl.length || 
				index < 0 || index >= barList.size() || index >= pl.length || vsaBar == null ){
			return;
		}
		
		for(Region region : Region.values()){
			if(pl[index] <= region.getUpperLimit() && pl[index] >= region.getLowerLimit()){
				vsaBar.setRegion(region);
				break;
			}
		}
	}
	
	private Region(String name, int ordinal, double upperLimit, double lowerLimit) {
		super(name, ordinal, upperLimit, lowerLimit);
	}
}
